<template>
  <em>
    <el-button @click="editClick" type="text" size="small">编辑</el-button>
    <forms :is_edit="true" :cur_this="cur_this" ref="edform"></forms>
  </em>
</template>

<script>
import forms from "./form";
export default {
  components: { forms },
  props: {
    datas: {
      type: Object,
      required: true
    },
    cur_this: {
      type: Object,
      required: null
    }
  },
  methods: {
    editClick() {
      const row = this.datas;
      const _this = this.$refs.edform;
      _this.roleIds = '';
      _this.form = {
        id: row.id,
        username: row.username,
        phone: row.phone,
        email: row.email,
        enabled: row.enabled,
        roles: [],
        dept: { id: row.dept ? row.dept.id : "" },
        job: { id: row.job ? row.job.id : "" }
      };
      let role = 0;
      row.roles.forEach(function(data, index) {
        role = data.id
        // _this.roleIds.push(data.id);
      });
      _this.roleIds = role
       console.log(role)
      _this.citys = {
        cityId: row.cityId,
        provinceId: row.provinceId,
        districtId: row.districtId
      };
      _this.deptId = row.dept ? row.dept.id : '';
      _this.jobId = row.job ? row.job.id : "";
      _this.getJobs(_this.deptId);
      _this.dialog = true;
      _this.domInit(role);
    }
  }
};
</script>

<style lang="scss">
</style>
